#ifndef CORE_SPHERE_H
#define CORE_SPHERE_H
#include "Hitable.h"
#include <math.h>
#include <algorithm>
#include <iostream>
namespace RayTracer
{
	class Sphere : public Hitable 
	{
	public:
		Sphere() {}
		Sphere(vec3 cen, float r)
			: center(cen), radius(r), matPtr(nullptr) {};
		Sphere(vec3 cen, float r, std::shared_ptr<Material> mat) 
			: center(cen), radius(r), matPtr(mat) {};

		bool Hit(const Ray& r, float t_min, float t_max, HitRecord& rec) const;
		bool BoundingBox( AABB& output_box) const;
	private:
		static void GetSphereUV(const vec3& p, float& u, float& v) 
		{
			float PI = 3.14159f;
			auto theta = acos(-p.y);
			auto phi = atan2(-p.z, p.x) + PI;

			u = phi / (2 * PI);
			v = theta / PI;
		}
	public:
		vec3 center;
		float radius;
		std::shared_ptr<Material> matPtr;
	};
}
#endif // !CORE_SPHERE_H
